package com.zhongxi.guoyuan.view.personalCenter;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.widget.ImageView;
import android.widget.TableLayout;
import android.widget.TextView;

import com.zhongxi.guoyuan.R;
import com.zhongxi.guoyuan.adapter.personCenter.CollectViewpagerAdapter;
import com.zhongxi.guoyuan.base.BaseActivity;
import com.zhongxi.guoyuan.fragment.collectfragment.CollectBeautyFragment;
import com.zhongxi.guoyuan.fragment.collectfragment.CollectRewardFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class NewCollectActivity extends BaseActivity {

    @Bind(R.id.tvTitle)
    TextView tvTitle;
    @Bind(R.id.ivBack)
    ImageView ivBack;
    @Bind(R.id.tabLayout)
    TabLayout tabLayout;
    @Bind(R.id.viewpager)
    ViewPager viewpager;

    private CollectViewpagerAdapter adapter;
    private List<Fragment> list = new ArrayList<>();
    private String[] title = {"美豆美容", "赚豆超市"};


    @Override
    protected void initView() {
        super.initView();
        setContentView(R.layout.activity_new_collect);
        ButterKnife.bind(this);
        tvTitle.setText("我的收藏");
        list.add(new CollectBeautyFragment());
        list.add(new CollectRewardFragment());

        adapter = new CollectViewpagerAdapter(getSupportFragmentManager(), list, title,this);
        viewpager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewpager);

        TabLayout.Tab tabAt = tabLayout.getTabAt(0);
        tabAt.setCustomView(adapter.getTabview0());
        TabLayout.Tab tabAt1 = tabLayout.getTabAt(1);
        tabAt1.setCustomView(adapter.getTabview1());
        viewpager.setCurrentItem(0);

    }

    @OnClick(R.id.ivBack)
    public void onViewClicked() {
        onBackPressed();
    }
}
